package com.example.graph;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class Fragment2 extends Fragment {

    private Button B1;
    private Button B2;
    private Button B3;

    public Fragment2(){
        super(R.layout.fragment2);
    }

    public void onViewCreated(@NonNull View view, @Nullable Bundle saveInstanceState){
        super.onViewCreated(view, saveInstanceState);

        B1 = getView().findViewById(R.id.button1);
        B2 = getView().findViewById(R.id.button2);
        B3 = getView().findViewById(R.id.button3);
        B1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                intent.setData(Uri.parse("https://www.baidu.com/"));
                startActivity(intent);
            }
        });

        B2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage("tv.danmaku.bili");
                startActivity(intent);
            }
        });

        B3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage("com.tencent.mtt");
                startActivity(intent);
            }
        });
    }
}
